package com.liser.southernstar.collection.ui.adapter;


import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.liser.southernstar.R;
import com.liser.southernstar.collection.model.vo.OrderItemVO;
import com.liser.southernstar.neleme.views.AddGoodsWidget;

import java.math.BigDecimal;
import java.util.List;

public class OrderCarAdapter extends BaseQuickAdapter<OrderItemVO, BaseViewHolder> {

    private AddGoodsWidget.OnAddClick onAddClick;

    public OrderCarAdapter(@Nullable List<OrderItemVO> data, AddGoodsWidget.OnAddClick onAddClick) {
        super(R.layout.adapter_order_car, data);
        this.onAddClick = onAddClick;
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderItemVO item) {
        BigDecimal bigDecimal = item.getPrice().multiply(BigDecimal.valueOf(item.getSelectCount()));
        helper.setText(R.id.car_name, item.getName())
                .setText(R.id.car_price, item.getStrPrice(mContext, bigDecimal));
        AddGoodsWidget addGoodsWidget = helper.getView(R.id.car_addwidget);
        addGoodsWidget.setData(onAddClick, item);
    }
}
